define(["jquery","bbcare",
    "scprit/nutrition/app/departmentScheme/editScheme.servers.js",
    "scprit/nutrition/app/departmentScheme/editScheme.ui.js",
    "scprit/nutrition/app/departmentScheme/editScheme.event.js"
    ],function($,$bb,$servers,$ui,$event){
    var editScheme = {};

    /**
     * 查询疗程库成功后的回调函数
     */
    var ajaxCourseLibirayCallBack = function(data){
        $ui.courseListInit({
            "id":"courses",
            "list":data
        });
        // select里的value变化时
        $("#courses select").change($event.onCourseChange);
        // 初始化
        $("#courses select").change();
    }

    editScheme.init = function(){
        var index = 0;
        $event.schemeDetails(index);
        $servers.ajaxCourseLibiray(ajaxCourseLibirayCallBack);
        var schemeId = $servers.getPageParams().schemeId;
        var topbars = [
            {
                "icon":"fa fa-external-link",
                "name":"发布方案",
                "callback":$event.onSchemePublish,
                "params":{"schemeId":schemeId}
            },
            {
                "icon":"fa fa-times",
                "name":"删除方案",
                "callback":$event.onSchemeDel,
                "params":{"schemeId":schemeId}
            }
        ];
        $bb.toolbar(topbars);
    }

    return editScheme;
});